<!DOCTYPE html>
<html>
<head>
    <meta charset=utf-8>
    <meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1">
</head>

<body>
    <div>01-日期格式化函数</div>
    <script>
        const dateFormat = (data,format)=>{
            var day = data.getDate()
            var month = data.getMonth()+1
            var year = data.getFullYear()

            format = format.replace(/yyyy/,year)
            format = format.replace(/MM/,month)
            format = format.replace(/dd/,day)
            return format
        }


      console.log( dateFormat(new Date('2020-12-01'),'yyyy/MM/dd'))
       dateFormat(new Date('2020-12-01'),'yyyy/MM/dd')
       dateFormat(new Date('2020-12-01'),'yyyy年MM/月dd日')
    </script>
</body>

</html>

